// services/api/user.ts
import { http } from '@/lib/request'
import type { User } from '../types'

export const userService = {
  // 获取用户列表
  getUsers: async () => {
    return http.get<User[]>('/api/users')
  },

  // 获取单个用户
  getUser: async (id: number) => {
    return http.get<User>(`/api/users/${id}`)
  },

  // 创建用户
  createUser: async (userData: Partial<User>) => {
    return http.post<User>('/api/users', userData)
  },

  // 更新用户
  updateUser: async (id: number, userData: Partial<User>) => {
    return http.put<User>(`/api/users/${id}`, userData)
  },

  // 删除用户
  deleteUser: async (id: number) => {
    return http.delete<void>(`/api/users/${id}`)
  },
}
